<template>
  <div class="blogNav-box flex-row">
    <ul v-show="isShowMenu">
      <li v-for="(item, index) in blogNavs" :key="item.name" :class="index === blogNavIndex ? 'cp active' : 'cp'" @click="goScroll(index ,item.offsetTop)">{{item.name}}</li>
    </ul>
    <div class="icon-box cp" @click="onClickMenu">
      <i class="el-icon-menu"></i>
    </div>
  </div>
</template>

<script>
export default {
  name: 'BlogNav',
  props: {
    blogNavs: {
      type: Array,
      required: true
    },
    blogNavIndex: {
      type: Number,
      required: true
    }
  },
  data() {
    return {
      isShowMenu: true
    }
  },
  methods: {
    goScroll(index, offsetTop) {
      this.$emit('goScroll', index, offsetTop)
    },
    onClickMenu() {
      this.isShowMenu = !this.isShowMenu
    }
  }
}
</script>

<style scoped lang="less">
.blogNav-box{
  position: fixed;
  top: 250px;
  right: 30px;
  bottom: 0;
  .icon-box{
    i{
      font-size: 30px;
    }
    &:hover{
      i{
        color: #3593f2;
      }
    }
  }
  ul{
    border-left: 1px #e4e7ed solid;
    background: #e9ecef;
    padding-top: 10px;
    border-radius: 10px;
    height: 80%;
    overflow-y: auto;
    li{
      font-size: 14px;
      padding: 0 20px;
      color: #303133;
      font-weight: 500;
      margin-bottom: 16px;
      height: 40px;
      line-height: 40px;
      &.active{
        border-left: 2px #3593f2 solid;
        color: #3593f2;
      }
      &:hover{
        color: #3593f2;
      }
    }
  }
}
</style>